package edu.buaa.traffic.transaction.internal;

import edu.buaa.common.transaction.AbstractTransaction;
import edu.buaa.utils.Helper;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class NodeNeighborRoadTx extends AbstractTransaction {

    private long nodeId;

    public NodeNeighborRoadTx(long nodeId, List<String> roadIds) {
        this.setTxType(TxType.tx_query_node_neighbor_road);
        this.nodeId = nodeId;
        Result r = new Result();
        r.setRoadIds(roadIds);
        this.setResult(r);
    }

    public NodeNeighborRoadTx(){}

    public long getNodeId() {
        return nodeId;
    }

    public void setNodeId(long nodeId) {
        this.nodeId = nodeId;
    }

    @Override
    public boolean validateResult(AbstractTransaction.Result result) {
        return Helper.validateResult(((Result) this.getResult()).getRoadIds(), ((Result) result).getRoadIds());
    }

    public static class Result extends AbstractTransaction.Result{
        List<String> roadIds;

        public List<String> getRoadIds() {
            return roadIds;
        }

        public void setRoadIds(List<String> roadIds) {
            this.roadIds = roadIds;
        }
    }
}
